package com.inspsys.algorithms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.algorithms.domain.AlgorithmsDataImage;
import com.inspsys.algorithms.service.IAlgorithmsDataImageService;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 图像处理算法Controller
 * 
 * @author inspsys
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/algorithms/algorithms_image")
public class AlgorithmsDataImageController extends BaseController
{
    @Autowired
    private IAlgorithmsDataImageService algorithmsDataImageService;

    /**
     * 查询图像处理算法列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlgorithmsDataImage algorithmsDataImage)
    {
        startPage();
        List<AlgorithmsDataImage> list = algorithmsDataImageService.selectAlgorithmsDataImageList(algorithmsDataImage);
        return getDataTable(list);
    }

    /**
     * 导出图像处理算法列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:export')")
    @Log(title = "图像处理算法", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgorithmsDataImage algorithmsDataImage)
    {
        List<AlgorithmsDataImage> list = algorithmsDataImageService.selectAlgorithmsDataImageList(algorithmsDataImage);
        ExcelUtil<AlgorithmsDataImage> util = new ExcelUtil<AlgorithmsDataImage>(AlgorithmsDataImage.class);
        util.exportExcel(response, list, "图像处理算法数据");
    }

    /**
     * 获取图像处理算法详细信息
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(algorithmsDataImageService.selectAlgorithmsDataImageById(id));
    }

    /**
     * 新增图像处理算法
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:add')")
    @Log(title = "图像处理算法", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgorithmsDataImage algorithmsDataImage)
    {
        return toAjax(algorithmsDataImageService.insertAlgorithmsDataImage(algorithmsDataImage));
    }

    /**
     * 修改图像处理算法
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:edit')")
    @Log(title = "图像处理算法", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgorithmsDataImage algorithmsDataImage)
    {
        return toAjax(algorithmsDataImageService.updateAlgorithmsDataImage(algorithmsDataImage));
    }

    /**
     * 删除图像处理算法
     */
    @PreAuthorize("@ss.hasPermi('algorithms:algorithms_image:remove')")
    @Log(title = "图像处理算法", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(algorithmsDataImageService.deleteAlgorithmsDataImageByIds(ids));
    }
}
